/**
 * Created by Jack Xue on 20101030
 */
package org.code.jack.jweberp.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.springframework.stereotype.Controller;

@Controller("/main")
public class MainAction extends BaseAction {

	
	@Override
	protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		Object user = request.getSession().getAttribute("currentUser");
		if(user != null){
			return mapping.findForward("success");
		}
		return mapping.findForward("login");
	}
	
	public ActionForward logout(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		request.getSession().removeAttribute("currentUser");
		return mapping.findForward("login");
	}

}
